<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:of="http://omnifaces.org/functions"
>
	<ui:define name="description">
		<p>
			The <code>@FacesValidator</code> is by default not eligible for dependency injection by <code>@Inject</code> nor <code>@EJB</code>.
			There is a 
			<a href="http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#GettingAnEJBInFacesConverterAndFacesValidator">workaround</a>
			for EJB, but this is nasty and doesn't work out for CDI.
			<a href="http://stackoverflow.com/q/7572335/157882">Another way</a>
			would be to make it a JSF or CDI managed bean, however this doesn't register the converter instance into the JSF application context,
			and hence you won't be able to make use of 
			<a href="http://docs.oracle.com/javaee/6/api/javax/faces/application/Application.html#createValidator(java.lang.String)"><code>Application#createValidator()</code></a> 
			on it. 
		</p>
		<p>
			Initially, this should be solved in JSF 2.2 which comes with new support for dependency injection in among others all 
			<code>javax.faces.*.*Factory</code>, <code>NavigationHandler</code>, <code>ResourceHandler</code>, 
			<code>ActionListener</code>, <code>PhaseListener</code> and <code>SystemEventListener</code> instances.
			The <code>Converter</code> and <code>Validator</code> were initially also among them, but they broke a TCK test and were at the last moment removed from dependency injection support. 
		</p>
		<p>
			The support is expected to come back in JSF 2.3, but we just can't wait any longer.
			<a href="http://myfaces.apache.org/extensions/cdi/" rel="nofollow">MyFaces CODI</a>
			has support for it, but it requires an additional <code>@Advanced</code> annotation.
			OmniFaces solves this by implicitly making all <code>@FacesValidator</code> instances eligible for dependency injection <strong>without any further modification</strong>, like as JSF 2.2 would initially do, hereby providing a transparent bridge of the code to the upcoming JSF 2.3.
		</p>
	</ui:define>

	<ui:define name="demo">
		<h3>Submit the form</h3>
		<p>Validator will print itself and both the injected EJB and CDI bean in a faces message. Note: EJB is stateless and CDI bean is request scoped.</p>
		<h:form>
			<h:inputText validator="someValidator" />
			<h:commandButton value="Submit">
				<f:ajax execute="@form" render="@form" />
			</h:commandButton>
			<h:messages />
		</h:form>
	</ui:define>
</ui:composition>